home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH15 / EX15_1.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-03-25  |  1.7 KB  |  105 lines

  1. ; EX15_1.asm
  2. ;
  3. ; This program demonstrates the proper use of the 80x86 string instructions.
  4.  
  5.         .386
  6.         option        segment:use16
  7.  
  8.         include     stdlib.a
  9.         includelib    stdlib.lib
  10.  
  11.  
  12. dseg        segment    para public 'data'
  13.  
  14. Buffer1        byte    2048 dup (0)
  15. Buffer2        byte    2048 dup (0)
  16.  
  17. dseg        ends
  18.  
  19.  
  20. cseg        segment    para public 'code'
  21.         assume    cs:cseg, ds:dseg
  22.  
  23. Main        proc
  24.         mov    ax, dseg
  25.         mov    ds, ax
  26.         mov    es, ax
  27.         meminit
  28.  
  29.  
  30. ; Demo of the movsb, movsw, and movsd instructions
  31.  
  32.         print
  33.         byte    "The following code moves a block of 2,048 bytes "
  34.         byte    "around 100,000 times.",cr,lf
  35.         byte    "The first phase does this using the movsb "
  36.         byte    "instruction; the second",cr,lf
  37.         byte    "phase does this using the movsw instruction; "
  38.         byte    "the third phase does",cr,lf
  39.         byte    "this using the movsd instruction.",cr,lf,lf,lf
  40.         byte    "Press any key to begin phase one:",0
  41.  
  42.         getc
  43.         putcr
  44.  
  45.         mov    edx, 100000
  46.  
  47. movsbLp:    lea    si, Buffer1
  48.         lea    di, Buffer2
  49.         cld
  50.         mov    cx, 2048
  51.     rep    movsb
  52.         dec    edx
  53.         jnz    movsbLp
  54.  
  55.         print
  56.         byte    cr,lf
  57.         byte    "Phase one complete",cr,lf,lf
  58.         byte    "Press any key to begin phase two:",0
  59.  
  60.         getc
  61.         putcr
  62.  
  63.         mov    edx, 100000
  64.  
  65. movswLp:    lea    si, Buffer1
  66.         lea    di, Buffer2
  67.         cld
  68.         mov    cx, 1024
  69.     rep    movsw
  70.         dec    edx
  71.         jnz    movswLp
  72.  
  73.         print
  74.         byte    cr,lf
  75.         byte    "Phase two complete",cr,lf,lf
  76.         byte    "Press any key to begin phase three:",0
  77.  
  78.         getc
  79.         putcr
  80.  
  81.         mov    edx, 100000
  82.  
  83. movsdLp:    lea    si, Buffer1
  84.         lea    di, Buffer2
  85.         cld
  86.         mov    cx, 512
  87.     rep    movsd
  88.         dec    edx
  89.         jnz    movsdLp
  90.  
  91.  
  92. Quit:        ExitPgm            ;DOS macro to quit program.
  93. Main        endp
  94.  
  95. cseg        ends
  96.  
  97. sseg        segment    para stack 'stack'
  98. stk        db    1024 dup ("stack   ")
  99. sseg        ends
  100.  
  101. zzzzzzseg    segment    para public 'zzzzzz'
  102. LastBytes    db    16 dup (?)
  103. zzzzzzseg    ends
  104.         end    Main
  105.